const mongoose = require('mongoose');
const md5 = require('../util/md5');
const baseModel = require('./base-model');
// 声明user数据类型
const userSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true
  },
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true,
    set: (value) => md5(value), // 设置的是进行加密
    select: false // 查询的时候是否返回该字段
  },
  phone: {
    type: String,
    required: true
  },
  image: {
    type: String,
    default: null
  },
  cover: {
    type: String,
    default: null
  },
  channelIds: {
    type: String,
    default: null
  },
  subscribeCount: {
    type: Number,
    default: 0
  },
  ...baseModel
});

module.exports = userSchema;
